/*
 * @Author: zxh
 * @Email: 1271027008@qq.com
 * @Date: 2020-02-24 08:53:28
 * @Descripttion: 
 */
import { Injectable } from '@angular/core';
import { SubwarehouseManageService } from '../../basedata-manage/subwarehouse-manage/subwarehouse-manage.service';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from "rxjs";
import { MaterialRelationService } from '../../basedata-manage/material-relation/material-relation.service'
import { UserManageService } from '../../../system-manage/user-manage/user-manage.service'

@Injectable({
  providedIn: 'root'
})
export class BatchreservedListService {

  private ylListUrl = '/api/batchReserve'
  private cancelYL = '/api/batchReserve/cancels'
  private getPCUrl = '/api/stockBatch/getall'

  constructor(
    private SubwarehouseManageService:SubwarehouseManageService,
    private http:HttpClient,
    private MaterialRelationService:MaterialRelationService,
    private UserManageService:UserManageService
  ) { }

  // 获取所有库房
  getAllKF():Observable<any>{
    return this.SubwarehouseManageService.getKFAllList()
  }

  // 获取物料编码
  getMaterialCode(data):Observable<any>{
    return this.MaterialRelationService.getAll(data).pipe()
  }

  // 获取批次列表
  getPCList(data):Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.get(this.getPCUrl,{params:_dataJson}).pipe()
  }

  // 获取人员列表
  getUserList(data):Observable<any>{
    return this.UserManageService.getDepartMember(data).pipe()
  }

  // 获取库房批次预留列表
  getylList(data): Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.get(this.ylListUrl,{params:_dataJson}).pipe()
  }

  // 新增
  addyl(data): Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.post(this.ylListUrl,_dataJson).pipe()
  }
  // 修改
  edityl(data): Observable<any>{
    let _dataJson = {
      ...data
    }
    return this.http.put(this.ylListUrl,_dataJson).pipe()
  }

  // 取消预留
  cancelyl(data): Observable<any>{
    return this.http.post(this.cancelYL,data).pipe()
  }
}
